package com.watering.plan;

import android.app.Activity;
import android.app.NotificationManager;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.Toast;

/*
 *  Main Menu class, deals with the events 
 *  on the buttons, starting intents to the 
 *  classes that deal with the other screens.
 *  
 *  Layout : menu.xml
 *  Img : background.png  
 *  		(this is the first time used)
 */

public class MainMenu extends Activity {
	MainNotifier mn;
	NotificationManager mNM;
	Intent service;
	
	@Override
	  public void onCreate(Bundle savedInstanceState) 
	 {
	     super.onCreate(savedInstanceState);
	     setContentView(R.layout.menu);  
	     
	     service = new Intent(MainMenu.this, NotificationService.class);
	     startService(service);
	     
	     Button NewPlantButton = (Button) findViewById(R.id.newplant_button);
	     NewPlantButton.setOnClickListener(new OnClickListener() {
	         public void onClick(View v) {
	        	Intent myIntent = new Intent(MainMenu.this, NewPlant.class);
	     		startActivity(myIntent); 
	         }
	     });
	     
	     Button CheckPlantsButton = (Button) findViewById(R.id.checkplants_button);
	     CheckPlantsButton.setOnClickListener(new OnClickListener() {
	         public void onClick(View v) {
	        	Intent myIntent = new Intent(MainMenu.this, CheckPlants.class);
	     		startActivity(myIntent); 
	         }
	     });
	     
	     Button ScheduleButton = (Button) findViewById(R.id.schedule_button);
	     ScheduleButton.setOnClickListener(new OnClickListener() {
	         public void onClick(View v) {
	        	 Intent myIntent = new Intent(MainMenu.this, Schedule.class);
	     		startActivity(myIntent); 
	         }
	     });
	     
	     Button PlantAdviceButton = (Button) findViewById(R.id.plantadvice_button);
	     PlantAdviceButton.setOnClickListener(new OnClickListener() {
	         public void onClick(View v) {
	        	 Intent myIntent = new Intent(MainMenu.this, PlantAdvice.class);
	     		startActivity(myIntent); 
	         }
	     });
	     
	     Button HelpButton = (Button) findViewById(R.id.help_button);
	     HelpButton.setOnClickListener(new OnClickListener() {
	         public void onClick(View v) {
	        	 Intent myIntent = new Intent(MainMenu.this, Help.class);
	     		startActivity(myIntent); 
	         }
	     });
	     
	     final Button DisableNotification = (Button) findViewById(R.id.disable_notifications);
	     DisableNotification.setOnClickListener(new OnClickListener() {
	         public void onClick(View v) { 
	        	 stopService(service);
	        	 NotificationManager mNM = (NotificationManager)getSystemService(NOTIFICATION_SERVICE);
	        	 mNM.cancelAll();
        	//     Toast.makeText(MainMenu.this, "Notification disabled",
	        //		                 Toast.LENGTH_LONG).show();
        	     DisableNotification.setText("Notifications Disabled");
        	 //    DisableNotification.setTextColor(1);
        	     DisableNotification.setClickable(false);
	         }
	     });
	     
	   }
	
}
     


